/*
 * CUtil.java
 *
 * Copyright (c) 2009 Giles Millward (Manigra). All rights reserved.
 *
 * This file is part of JRogueDPS.
 *
 * JRogueDPS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JRogueDPS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JRogueDPS.  If not, see <http://www.gnu.org/licenses/>.
 */

package dpssystem;

/**
 *
 * @author Mani
 */
public class CUtil {
    static public double trunc3(final double doubleNumber) {
        return Math.floor(doubleNumber * 1000.0 +.5)/1000.0;
    }

    static public double trunc4(final double doubleNumber) {
        return Math.floor(doubleNumber * 10000.0 +.5)/10000.0;
    }

    static public double trunc5(final double doubleNumber) {
        return Math.floor(doubleNumber * 100000.0 +.5)/100000.0;
    }

    static public double trunc6(final double doubleNumber) {
        return Math.floor(doubleNumber * 1000000.0 +.5)/1000000.0;
    }

    static public double trunc2(final double doubleNumber) {
        return Math.floor(doubleNumber * 100.0 +.5)/100.0;
    }

    static public double trunc1(final double doubleNumber) {
        return Math.floor(doubleNumber * 10.0 +.5)/10.0;
    }

    static public double trunc(final double doubleNumber) {
        return Math.floor(doubleNumber +.5);
    }

    static public double getAgiToAp(final double doubleNumber) {
        return doubleNumber;
    }

    static public double getAgiToArmor(final double doubleNumber) {
        return doubleNumber * 2.0;
    }

    static public double getAgiToCrit(final double doubleNumber) {
        return doubleNumber * (1.0 / 83.33333333);
    }

    static public double getAgiToDodge(final double doubleNumber) {
        return doubleNumber * (1.0 / 20.0);
    }

    static public double getCritRatingToCrit(final double doubleNumber) {
        return doubleNumber * (1.0 /45.90598679);
    }

    static public double getCritRatingToSpellCrit(final double doubleNumber) {
        return doubleNumber / 45.905983;
    }

    static public double getExpRatingToExp(final double doubleNumber) {
        return doubleNumber * (1.0 / 8.2);
    }

    static public double getExpToDodgeParryReduction(final double doubleNumber) {
        return doubleNumber * (0.25);
    }

    static public double getHasteRatingToHaste(final double doubleNumber) {
        return doubleNumber * (1.0 / 32.79 );
    }

    static public double getHitRatingToHit(final double doubleNumber) {
        return doubleNumber * (1.0 / 32.79);
    }

    static public double getStaminaToHP(final double doubleNumber) {
        return doubleNumber * (10.0);
    }

    static public double getStrengthToAP(final double doubleNumber) {
        return doubleNumber;
    }

    static public double getArmorPenRatingToArmorReduction(final double doubleNumber) {
        return doubleNumber * 1.25 / 1539.529991;
    }

    static public double getMitigationPercent(double p_armor)
    {
        return Math.max(0, p_armor / (p_armor + 15232.5));
    }
    
    static public double getHitRatingToSpellHit(final double doubleNumber)
    {
        return doubleNumber / 26.231990;
    }
    static public double getAvgSpellResistance()
    {
        // Based on average spell resistance formula
        //average resistance = (target resistance / (caster level * 5)) * 0.75
        // = ((level difference * resistance per level) / (80 * 5)) * 0.75
        // = ((3 * 8) / (80 * 5)) * 0.75
        // = (24 / 400) * 0.75
        // = (0.06 * 0.75)

        return 0.04;
    }
}
